package com.edu.exam.enums.assessment;

/**
 * 相似度级别枚举
 */
public enum SimilarityLevel {
    IDENTICAL("IDENTICAL", "完全相同"),
    VERY_HIGH("VERY_HIGH", "极高相似"),
    HIGH("HIGH", "高相似"),
    MEDIUM("MEDIUM", "中等相似"),
    LOW("LOW", "低相似"),
    VERY_LOW("VERY_LOW", "极低相似"),
    NONE("NONE", "无相似"),
    UNCERTAIN("UNCERTAIN", "不确定");

    private final String code;
    private final String description;

    SimilarityLevel(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 从代码创建枚举实例
     *
     * @param code 枚举代码
     * @return 对应的枚举实例
     * @throws IllegalArgumentException 如果代码无效
     */
    public static SimilarityLevel fromCode(String code) {
        for (SimilarityLevel level : values()) {
            if (level.getCode().equals(code)) {
                return level;
            }
        }
        throw new IllegalArgumentException("Unknown SimilarityLevel code: " + code);
    }

    /**
     * 从描述创建枚举实例
     *
     * @param description 枚举描述
     * @return 对应的枚举实例
     * @throws IllegalArgumentException 如果描述无效
     */
    public static SimilarityLevel fromDescription(String description) {
        for (SimilarityLevel level : values()) {
            if (level.getDescription().equals(description)) {
                return level;
            }
        }
        throw new IllegalArgumentException("Unknown SimilarityLevel description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}